<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <title>Getting Started: Serving Web Content</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <script src="https://s3.pstatp.com/cdn/expire-1-M/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<span>hello boy!</span>

    <div>
        <form action="index" id="frm">
            <input type="text" name="dname">
            <input type="text" name="loc">
            <input type="button" value="提交" id="but" >
        </form>
        <button onclick="sendAjaxGet()">发送请求GET</button>
    </div>
    <input>
        <input id="file" type="file">请选择一个文件</input>
        <button onclick="upload()">上传文件</button>
    </div>

<script type="text/javascript">
        function sendAjaxGet() {
            $.ajax({
                type: "get",
                url: "http://localhost:8081/file/upload",
                success: function(data){
                    console.log(data);
                },
                error: function (message) {

                }
            });
        }
        function upload() {
            var file=$("#file")[0].files[0];
            var formData = new FormData();
            formData.append("file2",file);
            $.ajax({
                type: "post",
                url: "http://localhost:8081/file/upload/uploadFile",
                data: formData,
                processData: false,
                contentType:false,
                success: function (data) {
                    console.log(data);
                }
            });
        }

</script>

</body>
</html>
